<SCRIPT LANGUAGE="JavaScript">
<!--
var base_url = '<?php echo site_url();?>';
//-->
</SCRIPT>
<?php echo css('upload.css');?>
<?php echo js('jquery.form.js');?>
<?php echo js('jquery.MultiFile.js');?>
<?php echo js('jquery.MetaData.js');?>
<?php echo js('jquery.blockUI.js');?>
<?php echo js('jquery.anchor.js');?>

<SCRIPT LANGUAGE="JavaScript">
<!--
$(document).ready(function() { 
    var options = { 
        target:         '#ajax_gallery_content',
        beforeSubmit:   showRequest,
        success:        showResponse,
        clearForm: 		true,
        resetForm: 		false,
        timeout:   		30000 
    }; 
    $('#upload').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
}); 
function showRequest(formData, jqForm, options) 
{ 
	$(document).ajaxStop($.unblockUI);
	$.blockUI({ message: '<br /><h2><img src="<?php echo image_url('admin/upload/ajax-loader.gif'); ?>" /> 正在上傳圖片,請稍候...</h2><br />' }); 
} 
function showResponse(responseText, statusText, xhr, $form)  
{
	$("#upload_result_list").toanchor({anchortag: "href",anchorSmooth: false});
	$("#upload_result_list").click();
	$('input:file').MultiFile('reset');
	$('#upload_info').submit(function() { 
	      $(this).ajaxSubmit(option_info); 
	      return false; 
	});
} 
//-->
</SCRIPT>

<div class="post">
		<div class="post_title">
			<h1>圖片上傳</h1>
		</div>
		<div class="post_body">
		<?php $this->load->view('admin/partials/notices') ?>
 		<?php echo form_open_multipart('admin/galleries/do_upload',array('class' => '', 'id' => 'upload', 'enctype' => 'multipart/form-data'));?>
		<table width="100%">
		<tr>
			 <td colspan="2">
			 		<br/>
					<br/>
			 		<fieldset id="main">
				 		<legend><strong>圖片設置</strong></legend>
				 		<div id="upload-put">
						  <table width="100%" border="0" cellpadding="2" cellspacing="2" bgcolor="#daecf6">
						    <tr>
						      <td width="15%">圖片分類：</td>
						      <td width="85%"><select name="category_id">
										<option value="0">-----------</option>
										<?php foreach($categories as $key => $category):?>
										<option value="<?php echo $category->id?>"><?php echo $category->name?></option>
										<?php endforeach;?>
										</select></td>
						    </tr>
						    <tr>
						      <td>選擇作品：</td>
						      <td><input type="file" name="userfile[]" size="20" class="multi" />(提示：一次選擇一張作品，可多選)</td>
						    </tr>
						  </table>
						  <div class="clearfix"></div></div>
						</div>
					</fieldset>
					<br/>
					<br/>
				
				<fieldset id="main">
					<legend><strong>上傳圖片列表</strong></legend>
					<div id="upload-name"></div>					
					<div><input type="submit" name="button2" id="put1" value="上傳" /></div>

			 	</fieldset>
			 </td>
		</tr>
		<tr>
			 <td colspan="2">&nbsp;</td>
		</tr>
		</table>
	<?php echo form_close(); ?>
	</div>
	<!-- 顯示上傳結果列表div -->
	<a id="upload_result_list" href="#upload_result_list"></a>
	<div id="ajax_gallery_content" class="post_body nicelist"></div>
	<!-- /顯示上傳結果列表div -->
</div>